#!/bin/bash

echo "========================================"
echo "Cola架构用户管理系统启动脚本"
echo "========================================"

echo "1. 检查Java环境..."
if ! command -v java &> /dev/null; then
    echo "错误：未找到Java环境，请先安装JDK 8+"
    exit 1
fi
java -version

echo "2. 检查Maven环境..."
if ! command -v mvn &> /dev/null; then
    echo "错误：未找到Maven环境，请先安装Maven 3.6+"
    exit 1
fi
mvn -version

echo "3. 编译项目..."
mvn clean compile
if [ $? -ne 0 ]; then
    echo "错误：项目编译失败"
    exit 1
fi

echo "4. 启动应用..."
echo "请确保MySQL和Redis服务已启动"
echo "访问地址：http://localhost:8080"
echo "按Ctrl+C停止应用"
echo "========================================"
mvn spring-boot:run
